<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type = "text/javascript" src = "https://d3js.org/d3.v4.min.js"></script>
</head>

<body>
    <ul id="list">
        <li></li>
        <li></li>
    </ul>
    <button onclick="move()">点击删除</button>
    

    <script>
    // .text(function (d, i) {
    //     console.log(d); 
    //     console.log(i);
    //     console.log(this); 
    //     return d;
    //  });
    // .text的时候我们还可以看对应的数字和索引
    d3.select("#list").selectAll("li").data([10, 20, 30, 25, 15]).text(function(d){return d}).enter().append("li").text(function (d, i) {
   console.log(d); // the data element
   console.log(i); // the index element
   console.log(this); // the current DOM object
   return d;
})
        function move(){
            console.log('hh');
            d3.select("#list").selectAll("li").data([1,2]).exit().remove()
        }

       
    </script>
</body>

</html>